Top
Photo by Austin Distel on Unsplash

Power Platform Pipelines pre-deployment approval flow


Some time ago I have recorded a video about using the pre-deployment actions in Power Platform Pipelines. These actions would allow you to create e.g. approval workflow. In this post I am describing actions, that the mentioned workflow is using.

The video I mentioned you can find here:

Pre-deployment configuration

To be able to use the pre-deployment actions, you need to open the “Deployment Pipeline Configuration” app in you Power Platform Pipelines host environment, then navigate to “Pipelines” and select a stage within a pipeline, where you want to activate the feature. Then select a checkbox “Pre-Deployment Step Required”:

Pre-Deployment Step Required

Power Automate configuration

Trigger

The trigger that you use is: “When an action is performed”, and it should be configured as following:

Speaking about the “Action name”, there are several types, triggered based on various conditions, that you can choose from:

  • OnDeploymentCompleted – when the whole deployment is completed.
  • OnDeploymentRequested – when the actual deployment is requested.
  • OnDeploymentStarted – when the actual deployment is started.
  • OnPreDeploymentCompleted – when the pre-deployment stage is completed.
  • OnPreDeploymentStarted – when the pre-deployment is started – the request has been placed and the mentioned above checkbox is selected.

Approval

For the approval itself there is not really much to say. What is important, is that depending on the approval outcome – approved/ rejected, the deployment request must be updated with a different status:

  1. The action name would be “UpdatePreDeploymentStepStatus”.
  2. StageRunId is a value taken from the triggerBody() outputs (returned by the trigger action).
  3. PreDeploymentStepStatus when approved is 20 – this would complete this step successfully and then trigger the “OnDeploymentRequested” action. When rejected value should be set to 30 – which means the step ended up with an error.

Get exported solution files

There are two solution files generated each time a deployment is started. Unmanaged and managed. You can get these files in your process and store them in the file repository or code repository of your choice. For this purpose I am using the “HTTP with Azure AD” action. Then to get base64 encoded string for:

  1. Managed solution file: use the dynamic outcome from trigger: @{triggerOutputs()?['body/OutputParameters/ArtifactFileDownloadLink']}
  2. Unmanaged solution file: replace ArtifactDownloadLink in the value above with ArtifactFileUnmanagedDownloadLink: @{replace(triggerOutputs()?['body/OutputParameters/ArtifactFileDownloadLink'], 'artifactfile', 'artifactfileunmanaged')}

In the end use the: @{body('HTTP_with_Azure_AD')?['body']?['$content']} to retrieve the pure base64 string that you can use to create file in e.g. SharePoint or Github:

And that’s it! I hope this will be really helpful for you 🙂


Tomasz Poszytek

Hi, I am Tomasz. I am expert in the field of process automation and business solutions' building using Power Platform. I am Microsoft MVP and Nintex vTE.

4 Comments
  • Kyle Bowling

    Hi Tomasz – Great post. How did you setup the HTTP with Azure AD connection? Tying to build out a similar flow.

    August 31, 2023 at 5:25 pm Reply
  • Philipp Lucas

    Hi Tomasz,

    thanks alot for this article! MS documentation is still quite poor on this topic. Therefore it’salways helpful to see someone showing a working tutorial.

    However, since I had some issues setting up the connection for the “HTTP with Azure AD” connector myself, I would like to share what worked for me:

    Looking at the trigger outputs we can see the “ArtifactFileDownloadLink” is showing something like “https://org9999aaa9a9a9.crm4.dynamics.com/api/data/v9.0/deploymentartifacts([GUID])/artifactfile/$value”. Using the first part “https://org9999aaa9a9a9.crm4.dynamics.com/” in both connection inputs worked for me.

    October 26, 2023 at 12:54 pm Reply

Post a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.